#include "widget.h"
#include "ui_widget.h"
#include "widget1.h"
#include "form2_1.h"
#include "form2_2.h"
#include "form2_4.h"
#include "form2_5.h"
#include "form3_1.h"
#include "form2_4_2.h"
#include "form3_2.h"
#include "form4_1.h"
#include "project.h"
#include "widget4.h"

Widget::Widget(FlightBookingSystem& system,QWidget *parent)
    : bookingSystem(system),
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    bookingSystem.last=this;
    this->page1=new Widget1(bookingSystem,this);
    connect(this->page1,SIGNAL(back()),this,SLOT(comeBackToPrev1()));
    this->page2=new Widget2(bookingSystem);
    connect(this->page2,SIGNAL(back()),this,SLOT(comeBackToPrev2()));
    this->page3=new Widget3(bookingSystem);
    connect(this->page3,SIGNAL(back()),this,SLOT(comeBackToPrev3()));
    Flight flight;
    this->page4=new Widget4(bookingSystem,this,flight);
    connect(this->page4,SIGNAL(back()),this,SLOT(comeBackToPrev4()));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton1_clicked()
{
    this->close();
    this->page1->show();
}

void Widget::comeBackToPrev1()
{
    this->page1->hide();
    this->show();
}

void Widget::on_pushButton2_clicked()
{
    this->close();
    this->page2->show();
}

void Widget::comeBackToPrev2()
{
    this->page2->hide();
    this->show();
}

void Widget::on_pushButton3_clicked()
{
    this->close();
    this->page3->show();
}

void Widget::comeBackToPrev3()
{
    this->page3->hide();
    this->show();
}

void Widget::on_pushButton4_clicked()
{
    this->close();
    this->page4->show();
}

void Widget::comeBackToPrev4()
{
    this->page4->hide();
    this->show();
}

void Widget::on_pushButton5_clicked()
{
    this->page5=new Widget5(bookingSystem);
    connect(this->page5,SIGNAL(back()),this,SLOT(comeBackToPrev5()));
    this->close();
    this->page5->show();
}

void Widget::comeBackToPrev5()
{
    this->page5->hide();
    this->show();
}

void Widget::on_pushButton6_clicked()
{
    this->page6=new Widget6;
    this->close();
    this->page6->show();
}

void Widget::comeBackToPrev1_1()
{
    this->page1->page1_1->hide();
    this->show();
}

void Widget::comeBackToPrev2_3()
{
    this->bookingSystem.page2_1->page2_3->hide();
    this->show();
}

void Widget::comeBackToPrev2_4_1()
{
    this->bookingSystem.page2_1->page2_4_1->hide();
    this->show();
}

void Widget::comeBackToPrev2_4()
{
    this->bookingSystem.page2_4->hide();
    this->show();
}

void Widget::comeBackToPrev2_5()
{
    this->bookingSystem.page2_5->hide();
    this->show();
}

void Widget::comeBackToPrev3_1()
{
    this->bookingSystem.page3_1->hide();
    this->show();
}

void Widget::comeBackToPrev2_4_2()
{
    this->bookingSystem.page2_4_2->hide();
    this->show();
}

void Widget::comeBackToPrev3_2()
{
    this->bookingSystem.page3_2->hide();
    this->show();
}

void Widget::comeBackToPrev4_2()
{
    this->page4->page4_1->page4_2->hide();
    this->show();
}
